
package com.googlecode.cswish.util;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Jerry.Feng Date: 2004 17:11:04
 * @version $id: $
 */
public class HashCache {
    public static final int INIT_CAPACITY = 100;
    private Map map;    
    
    public HashCache() {
    	map = new HashMap(INIT_CAPACITY);
    }
    
    public HashCache(int initialCapacity) {
    	map = new HashMap(initialCapacity);
    }
    
    public void addElement(Object arg0, Object arg1) {
        map.put(arg0,arg1);
    }
    
    public Object getElement(Object arg0) {
        return map.get(arg0);
    }
    
    public int size() {
        return map.size();
    }
    
    public int capacity() {
        int capcity = map.size();
        if (capcity >= INIT_CAPACITY) {
            return 0;
        } else {
            return INIT_CAPACITY - capcity;
        }
    }
}
